FROM nginx:alpine

# 设置工作目录
WORKDIR /usr/share/nginx/html

# 创建必要的目录
RUN mkdir -p /usr/share/nginx/html/images/products

# 设置数据卷（用于挂载前端构建文件和配置）
VOLUME ["/usr/share/nginx/html", "/etc/nginx/conf.d", "/var/log/nginx"]

# 添加版本信息
ARG VERSION=unknown
ENV APP_VERSION=$VERSION
RUN echo $APP_VERSION > /usr/share/nginx/html/version.txt

# 暴露端口
EXPOSE 80

# 健康检查
HEALTHCHECK --interval=30s --timeout=3s CMD wget -q -O - http://localhost/ || exit 1 